﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using System;

// 响应拖拽事件
public class Touch : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler, IPointerDownHandler, IPointerUpHandler
{

    public Action<PointerEventData> OnDragBeginCallback;
    public Action<PointerEventData> OnDragEndCallback;
    public Action<PointerEventData> OnDragCallback;
    public Action<PointerEventData> OnPointerDownCallback;
    public Action<PointerEventData> OnPointerUpCallback;

    public void OnBeginDrag(PointerEventData eventData)
    {
        if (OnDragBeginCallback != null)
        {
            OnDragBeginCallback(eventData);
        }
    }

    public void OnDrag(PointerEventData eventData)
    {
        if (OnDragCallback != null)
        {
            OnDragCallback(eventData);
        }
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        if (OnDragEndCallback != null)
        {
            OnDragEndCallback(eventData);
        }
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        if (OnPointerDownCallback != null)
        {
            OnPointerDownCallback(eventData);
        }
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if (OnPointerUpCallback != null)
        {
            OnPointerUpCallback(eventData);
        }
    }
}
